<template>
  <div class="dashboard-editor-container">
    <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <!--<el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">-->
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :lg="16">
        <div class="app-title">
            <p>{{ time }}异常交易趋势</p>
        </div>
        <div>
          <line-chart :chart-data="lineChartData" :monthShow="lineChartData.monthShow"/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="app-title">
          <p>{{ time }}异常交易占比</p>
        </div>
        <div class="chart-wrapper">
          <pie-chart />
        </div>
      </el-col>
    </el-row>

    <!--<el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <raddar-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <bar-chart />
        </div>
      </el-col>
    </el-row>-->
  </div>
</template>

<script>
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
import RaddarChart from './components/RaddarChart'
import PieChart from './components/PieChart'
import BarChart from './components/BarChart'
import timeAgo from '@/filters/index'

const lineChartData = {
  newVisitis: {
    monthShow: true,
    monthData: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
    expectedData: [100, 120, 161, 134, 105, 160, 165, 140, 150, 110, 150, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145, 100, 120, 161, 134, 120],
    accounts: [100, 130, 90, 80, 150, 162, 140, 145, 100, 130, 120, 100]
  },
  messages: {
    monthShow: false,
    monthData: ['1', '2', '4', '5', '7', '8', '9', '10', '11', '12', '14', '15', '18', '20', '21', '23', '30', '31'],
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130],
    accounts: [100, 130, 90, 80, 150, 162, 140, 145, 100, 130, 120, 100]
  },
  purchases: {
    monthShow: false,
    monthData: ['1', '2', '4', '5', '7', '8', '9', '10', '11', '12', '14', '15', '18', '20', '21', '23', '30', '31'],
    expectedData: [80, 100, 121, 104, 105, 90, 100, 100, 120, 150, 140, 120, 90, 130],
    actualData: [120, 90, 100, 138, 142, 130, 130],
    accounts: [100, 130, 90, 80, 150, 162, 140, 145, 100, 130, 120, 100]
  }
}

export default {
  name: 'DashboardAdmin',
  components: {
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      time: undefined
    }
  },
  methods: {
    handleSetLineChartData(type, time) {
      this.time = time
      this.lineChartData = lineChartData[type]
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }
  .app-title {
    border-left: 5px solid #34BFA3;
    margin-top: 10px;
    p {
      line-height: 40px;
      margin-left: 22px;
    }
  }

  .chart-wrapper {
    background: #fff;
    /*padding: 31px 16px 18px;*/
    margin-bottom: 34px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
